package form;

import model.user.User;
import play.api.libs.Crypto;

/**
 * Created with IntelliJ IDEA.
 * User: Tom
 * Date: 7-2-14
 * Time: 15:00
 */
public class Signup {


    private String password;
    private String password_repeat;
    private String first_name;
    private String last_name;
    private String email;


    public String getEmail() {
        return email;
    }

    public void setEmail(String email) {
        if (email != null && !email.equals(""))
            this.email = email;
    }
    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        if (password != null && !password.equals(""))
            this.password = Crypto.encryptAES(password);
    }

    public String getPassword_repeat() {
        return password_repeat;
    }

    public void setPassword_repeat(String password_repeat) {
        if (password_repeat != null && !password_repeat.equals(""))
            this.password_repeat = Crypto.encryptAES(password_repeat);
    }

    public String getFirst_name() {
        return first_name;
    }

    public void setFirst_name(String first_name) {
        if (first_name != null && !first_name.equals(""))
            this.first_name = first_name;
    }

    public String getLast_name() {
        return last_name;
    }

    public void setLast_name(String last_name) {
        if (last_name != null && !last_name.equals(""))
            this.last_name = last_name;
    }

    public User toUser(){
        return new User(getEmail(), getPassword(), getFirst_name(), getLast_name());
    }


    public String toPrintStr(){
        return "Registration for form: " +
                "Email: " + email + " " +
                "First name: " + first_name + " " +
                "Last name: " + last_name + " " +
                "Password: " + password + " " +
                "Password repeated: " + password_repeat + " ";
    }
}
